package com.sgb.kjwl.view.ui.fragment.packers;

import static com.sgb.kjwl.utils.NumberConstant.TEAM_CONSTRUCTION;
import static com.sgb.kjwl.utils.NumberConstant.sIsBack;

import android.os.Bundle;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.SparseArray;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.core.util.Pair;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.bigkoo.pickerview.view.TimePickerView;
import com.google.android.material.tabs.TabLayout;
import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.aspectj.login.LoginCheck;
import com.sgb.kjwl.databinding.FragmentPackerChangeFirstBinding;
import com.sgb.kjwl.model.entity.user.AddressEntity;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.utils.NumberConstant;
import com.sgb.kjwl.view.ui.activity.manage.ManageActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.sgb.kjwl.view.ui.activity.manage.special.InviteMemberListActivity;
import com.sgb.kjwl.view.ui.activity.packers.FindPackersActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersEngineeringCompanyActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersEngineeringTenderActivity;
import com.sgb.kjwl.view.ui.activity.packers.PackersFindPeopleActivity;
import com.sgb.kjwl.view.ui.activity.packers.ServicesCompanyActivity;
import com.sgb.kjwl.view.ui.activity.quotedprice.QuotedPriceActivity;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.adapter.YoungAdapterOnItemClick;
import com.sgb.kjwl.view.ui.adapter.packers.MemberCompanyAdapter;
import com.sgb.kjwl.view.ui.adapter.packers.TeamMainPageTitleAdapter;
import com.sgb.kjwl.view.ui.fragment.HomeFragment3;
import com.sgb.kjwl.view.widget.packers.TeamMainCompanyPupWindow;
import com.sgb.kjwl.view.widget.packers.TeamMenuCanExpandView;
import com.sgb.kjwl.viewmodel.packers.PackerChangeFirstViewModel;
import com.sgb.link.entity.PickFilterEntity;
import com.sgb.link.router.PathTeam;
import com.sgb.link.view.widget.CustomXTabLayout;
import com.sgb.member.ui.activity.MemberInviteOrApplyActivity;
import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.refresh.SuperSwipeRefreshLayout;
import com.swgk.core.util.MToast;
import com.swgk.core.util.PickSelectEntity;
import com.swgk.core.util.SharedPreferenceUtil;
import com.swgk.core.view.CityPickBuilder;
import com.swgk.core.view.CityPickView;
import com.swgk.core.view.adapter.CommPagerAdapter;
import com.swgk.core.view.weiget.TopView;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author : younghow
 * @date : 2021/8/18 15:06
 * description:工队首页上半部的fragment
 */
public class PackersChangeFragment extends AppLazyFragment {

    private FragmentPackerChangeFirstBinding mBinding;
    private PackerChangeFirstViewModel mViewModel;
    private String mCityName;
    private String mCityNameTwo;
    private String mCity;
    private String mProvince;
    private String mCityTwo;
    private String mAreaNo;
    private String mProvinceTwo;
    private String mIndustryNo;
    private String mCategoryNo;
    private String mWorkNo;
    private String mIndustryNoTwo;
    private String mCategoryNoTwo;
    private String mWorkNoTwo;
    private String mSalaryTypeNo;
    private String mIndustryName;
    private String mIndustryNameTwo;
    private String mToastStr = "您还没有成员企业，快去邀请吧！";
    private String mJumpStr = "邀请成员";
    private String mWorkKindOneNo;
    private String mWorkKindOneName;
    private String mWorkKindTwoName;
    private String mWorkKindTwoNo;
    private String mWorkKindThreeNo;
    private int position;
    private int selectPosition;
    private int mCityPosition;
    private int mProvincePosition;
    private int mCityPositionTwo;
    private int mProvincePositionTwo;
    private int mWorkCityPosition1;
    private int mWorkCityPosition2;
    private int mWorkCityPosition3;
    private int mWorkCityPositionTwo1;
    private int mAreaPosition;
    private int mFirstSelectPosition;
    private int mTitleNumber;
    private int mWorkKindOnePosition;
    private int mWorkKindTwoPosition;
    private int mWorkKindThreePosition;
    private int mUserType = SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0);
    private CityPickView mWorkTypeView, mAreaView;
    private final List<List<AddressEntity<List<AddressEntity>>>> mWorkOpt2 = new ArrayList<>();
    private final List<List<List<AddressEntity>>> mWorkOpt3 = new ArrayList<>();
    private final List<List<AddressEntity<List<AddressEntity>>>> mWorkOptArea = new ArrayList<>();
    private final List<List<List<AddressEntity>>> mWorkOptDistance = new ArrayList<>();
    private TextView textView;
    private ArrayList<Fragment> list;
    private boolean mHaveLevel;
    private List<AddressEntity> mLevel;
    private MemberCompanyAdapter mMemberCompanyAdapter;
    private OptionsPickerView mWorkKindOne;
    private List<PickFilterEntity<List<PickFilterEntity>>> mWorkKind = new ArrayList<>();
    private TeamMainCompanyPupWindow mMainCompany;
    private TimePickerView timeEndPicker, timeEndPicker1;
    private String[] title = {"找工人", "找工作", "找工队", "找工程"};
    private List<AddressEntity> menuList;

    public static PackersChangeFragment newInstance() {
        PackersChangeFragment fragment = new PackersChangeFragment();
        Bundle bundle = new Bundle();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_packer_change_first, container, false);
        return mBinding.getRoot();
    }

    @Override
    protected void initView() {
        super.initView();
        mBinding.setLifecycleOwner(this);
        mViewModel = new ViewModelProvider(this).get(PackerChangeFirstViewModel.class);
        initViews();
        initButtonListener();
        initLiveData();

        HomeFragment3 homeFragment3 = (HomeFragment3) getParentFragment();
        if (homeFragment3 != null) {
            homeFragment3.mChangeAreaLiveData.observe(getViewLifecycleOwner(), aBoolean -> doRefresh());
        }
    }

    private void initLiveData() {
        initStatusLiveData();

        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
        linearLayoutManager.setOrientation(RecyclerView.HORIZONTAL);
        mBinding.rvMemberTitle.setLayoutManager(linearLayoutManager);
        List<PickFilterEntity> titleList = new ArrayList<>();
        PickFilterEntity pickFilterEntity = new PickFilterEntity();
        pickFilterEntity.setName("成员");
        pickFilterEntity.setNum(R.drawable.packer_first_content_title_member);
        titleList.add(pickFilterEntity);
        PickFilterEntity pickFilterEntity1 = new PickFilterEntity();
        pickFilterEntity1.setName("会员");
        pickFilterEntity1.setNum(R.drawable.packer_first_content_title_member_company);
        titleList.add(pickFilterEntity1);
        PickFilterEntity pickFilterEntity2 = new PickFilterEntity();
        pickFilterEntity2.setName("关注");
        pickFilterEntity2.setNum(R.drawable.packer_first_content_title_follow);
        titleList.add(pickFilterEntity2);
        PickFilterEntity pickFilterEntity3 = new PickFilterEntity();
        pickFilterEntity3.setName("推荐");
        pickFilterEntity3.setNum(R.drawable.packer_first_content_title_recommend);
        titleList.add(pickFilterEntity3);
        PickFilterEntity pickFilterEntity4 = new PickFilterEntity();
        pickFilterEntity4.setName("商机");
        pickFilterEntity4.setNum(R.drawable.packer_first_content_title_business_opportunity);
        titleList.add(pickFilterEntity4);
        PickFilterEntity pickFilterEntity5 = new PickFilterEntity();
        pickFilterEntity5.setName("分类");
        pickFilterEntity5.setNum(R.drawable.packer_first_content_title_classify);
        titleList.add(pickFilterEntity5);
        TeamMainPageTitleAdapter mTeamMainPageTitleAdapter = new TeamMainPageTitleAdapter(getContext(), titleList);
        mTeamMainPageTitleAdapter.setMostNumber(3);

        mBinding.rvMemberTitle.setAdapter(mTeamMainPageTitleAdapter);
        mTeamMainPageTitleAdapter.setItemSelect(true);
        mTeamMainPageTitleAdapter.setDefItem(0);
        mTeamMainPageTitleAdapter.setOnItemClick(new YoungAdapterOnItemClick<PickFilterEntity>() {
            @Override
            public void onItemClick(PickFilterEntity pickFilterEntity, int position) {
                if ("成员".equals(pickFilterEntity.getName())) {
                    mTitleNumber = 0;
                    mToastStr = "您还没有成员企业，快去邀请吧！";
                    mJumpStr = "邀请成员";
                    refresh();
                } else if ("会员".equals(pickFilterEntity.getName())) {
                    mTitleNumber = 1;
                    mToastStr = "您还没有会员企业，快去邀请吧！";
                    mJumpStr = "邀请会员";
                    refresh();
                } else if ("关注".equals(pickFilterEntity.getName())) {
                    mTitleNumber = 2;
                    mToastStr = "您还没有关注的企业，快去看看吧！";
                    mJumpStr = "企业大全";
                    refresh();
                } else if ("推荐".equals(pickFilterEntity.getName())) {
                    mTitleNumber = 3;
                    mToastStr = "暂无推荐企业";
                    refresh();
                } else {
                    MToast.showToast(getContext(), "功能开发中");
                }
            }
        });

        mViewModel.mSuccessWorkType.observe(getViewLifecycleOwner(), addressEntities -> {
            menuList = addressEntities;
            mBinding.swipeRefresh.setRefreshing(false);
            //设置分类金刚位菜单
            mBinding.teamMenu.initData(getChildFragmentManager(), addressEntities, new TeamMenuCanExpandView.OnItemClick() {
                @Override
                public void onItemClick(AddressEntity addressEntity, int position, int num) {
                    switch (mFirstSelectPosition) {
                        case 0:
                            com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",0), Pair.create("entity", addressEntity));
                            break;
                        case 1:
                            ActivityJump.jumpToActivity(getContext(), PackersFindPeopleActivity.class, Pair.create("entity", addressEntity), Pair.create("title", "找工人"));
                            break;
                        case 2:
                            if (position == 0) {
                                FindPackersActivity.start(getActivity(), TEAM_CONSTRUCTION);
                            } else if (position == 1) {
                                FindPackersActivity.start(getActivity(), NumberConstant.NUMBER_ONE);
                            } else if (position == 2) {
                                ActivityJump.jumpToActivity(getContext(), PackersEngineeringCompanyActivity.class);
                            } else if (position == 3) {
                                ActivityJump.jumpToActivity(getContext(), ServicesCompanyActivity.class);
                            }
                            break;
                        case 3:
                            ActivityJump.jumpToActivity(getContext(), QuotedPriceActivity.class, Pair.create("entity", addressEntity));
                            break;
                        case 4:
                            ActivityJump.jumpToActivity(getContext(), PackersEngineeringTenderActivity.class, Pair.create("entity", addressEntity));
                            break;
                        case 5:
                            if (position < 19) {
                                ActivityJump.jumpToActivity(getContext(), PackersEngineeringCompanyActivity.class, Pair.create("entity", addressEntity));
                            } else {
                                ActivityJump.jumpToActivity(getContext(), PackersEngineeringCompanyActivity.class);
                            }
                            break;
                        case 6:
                            break;
                        default:
                            break;
                    }
                }
            });
        });

        mViewModel.mSuccessWorkTypeForPop.observe(getViewLifecycleOwner(), addressEntities -> {
            for (AddressEntity<List<AddressEntity<List<AddressEntity>>>> addressEntity : addressEntities) {
                List<AddressEntity<List<AddressEntity>>> secondLevel = addressEntity.getChildren();
                if (secondLevel.size() <= 0) {
                    List<AddressEntity> addressEntities1 = new ArrayList<>();
                    addressEntities1.add(new AddressEntity("", "", ""));
                    secondLevel.add(new AddressEntity<>("", "", addressEntities1));
                }
                mWorkOpt2.add(secondLevel);
                List<List<AddressEntity>> list = new ArrayList<>();
                for (AddressEntity<List<AddressEntity>> child : addressEntity.getChildren()) {
                    List<AddressEntity> third = child.getChildren();
                    if (third.size() <= 0) {
                        third.add(new AddressEntity("", "", ""));
                    }
                    list.add(third);
                }
                mWorkOpt3.add(list);
            }
            mWorkTypeView = new CityPickBuilder(getContext(), (options1, options2, options3, v) -> {
                String areaName;
                try {
                    if (mWorkOpt3.get(options1).get(options2).get(options3) == null) {
                        areaName = "";
                    } else {
                        areaName = mWorkOpt3.get(options1).get(options2).get(options3).getName();
                        if (position == 0) {
                            mWorkCityPosition3 = options3;
                        }
                    }
                } catch (IndexOutOfBoundsException e) {
                    areaName = "";
                }
                String content = addressEntities.get(options1).getName() + (!"".equals(mWorkOpt2.get(options1).get(options2).getName()) ? "/" : "")
                        + mWorkOpt2.get(options1).get(options2).getName() + (!"".equals(areaName) ? "/" : "")
                        + areaName;
                if (position == 0) {
                    mBinding.tvSelectWorkType.setText(content);
                } else if (position == 1) {
                    mBinding.etInputAge.setText(content);
                }

                if (position == 0) {
                    mWorkCityPosition1 = options1;
                    mWorkCityPosition2 = options2;
                    mIndustryNo = addressEntities.get(options1).getNo();
                    mIndustryName = addressEntities.get(options1).getName();
                    mCategoryNo = mWorkOpt2.get(options1).get(options2).getNo();
                    mBinding.ivNation.setVisibility(View.VISIBLE);
                } else if (position == 1) {
                    mWorkCityPositionTwo1 = options1;
                    mIndustryNoTwo = addressEntities.get(options1).getNo();
                    mIndustryNameTwo = addressEntities.get(options1).getName();
                    mBinding.ivNation4.setVisibility(View.VISIBLE);
                }

                try {
                    if (position == 0) {
                        mWorkNo = mWorkOpt3.get(options1).get(options2).get(options3).getNo();
                    }
                } catch (IndexOutOfBoundsException e) {
                    mWorkNo = "";
                }
            }).setCancelColor(ContextCompat.getColor(getContext(), R.color.color_666666)).setTitleColor(ContextCompat.getColor(getContext(), R.color.color_969696)).build();
            mWorkTypeView.setPicker(addressEntities, position == 0 ? mWorkOpt2 : null, position == 0 ? mWorkOpt3 : null);
            mWorkTypeView.setSelectOptions(position == 0 ? mWorkCityPosition1 : mWorkCityPositionTwo1, position == 0 ? mWorkCityPosition2 : 0, position == 0 ? mWorkCityPosition3 : 0);
            mWorkTypeView.setTitleText(position == 0 ? "请选择工种" : "请选择专业");
            mWorkTypeView.show();
        });

        mViewModel.mSuccessArea.observe(getViewLifecycleOwner(), addressEntities -> {
            for (AddressEntity<List<AddressEntity<List<AddressEntity>>>> addressEntity : addressEntities) {
                List<AddressEntity<List<AddressEntity>>> secondLevel = addressEntity.getChildren();
                if (secondLevel.size() <= 0) {
                    List<AddressEntity> addressEntities1 = new ArrayList<>();
                    addressEntities1.add(new AddressEntity("", "", ""));
                    secondLevel.add(new AddressEntity<>("", "", addressEntities1));
                }
                mWorkOptArea.add(secondLevel);

                List<List<AddressEntity>> list = new ArrayList<>();
                for (AddressEntity<List<AddressEntity>> child : addressEntity.getChildren()) {
                    List<AddressEntity> third = child.getChildren();
                    if (third.size() <= 0) {
                        third.add(new AddressEntity("", "", ""));
                    }
                    list.add(third);
                }
                mWorkOptDistance.add(list);
            }
            mAreaView = new CityPickBuilder(getContext(), (options1, options2, options3, v) -> {
                String areaName = "";
                try {
                    if (mWorkOptDistance.get(options1).get(options2).get(options3) == null) {
                        areaName = "";
                    } else {
                        if (position == 1) {
                            mAreaPosition = options3;
                            areaName = mWorkOptDistance.get(options1).get(options2).get(options3).getName();
                        }
                    }
                } catch (IndexOutOfBoundsException e) {
                    areaName = "";
                }

                String content = addressEntities.get(options1).getName() + mWorkOptArea.get(options1).get(options2).getName() + (TextUtils.isEmpty(areaName) ? "" : areaName);
                if (position == 0) {
                    mBinding.etInputWorkArea.setText(content);
                } else if (position == 1) {
                    mBinding.tvSelectWorkProfessionalLevel.setText(content);
                }
                if (position == 0) {
                    mProvincePosition = options1;
                    mCityPosition = options2;
                    mProvince = addressEntities.get(options1).getNo();
                    mCity = mWorkOptArea.get(options1).get(options2).getNo();
                    mCityName = mWorkOptArea.get(options1).get(options2).getSimpleName();
                    mBinding.ivNation2.setVisibility(View.VISIBLE);
                } else {
                    mProvincePositionTwo = options1;
                    mCityPositionTwo = options2;
                    mAreaNo = mWorkOptDistance.get(options1).get(options2).get(options3).getNo();
                    mProvinceTwo = addressEntities.get(options1).getNo();
                    mCityTwo = mWorkOptArea.get(options1).get(options2).getNo();
                    mCityNameTwo = mWorkOptDistance.get(options1).get(options2).get(options3).getSimpleName();
                    mBinding.ivNation6.setVisibility(View.VISIBLE);
                }
            }).setCancelColor(ContextCompat.getColor(getContext(), R.color.color_666666)).setTitleColor(ContextCompat.getColor(getContext(), R.color.color_969696)).build();
            mAreaView.setPicker(addressEntities, mWorkOptArea, position == 1 ? mWorkOptDistance : null);
            mAreaView.setSelectOptions(position == 0 ? mProvincePosition : mProvincePositionTwo, position == 1 ? mCityPosition : mCityPositionTwo, position == 1 ? mAreaPosition : 0);
            mAreaView.setTitleText(position == 0 ? "请选择工作地" : "请选择工作地");
            mAreaView.show();
        });

        mViewModel.mSuccessIntelligenceLevel.observe(getViewLifecycleOwner(), addressEntities -> {
            if (addressEntities.size() > 0) {
                mHaveLevel = true;
                mLevel = addressEntities;
                mBinding.tvSpecialLevel.setText(addressEntities.get(0).getName().contains("总包") ? addressEntities.get(0).getName() : String.format("总包%s", addressEntities.get(0).getName()));
                mBinding.tvOneLevel.setText(addressEntities.get(1).getName().contains("总包") ? addressEntities.get(1).getName() : String.format("总包%s", addressEntities.get(1).getName()));
                mBinding.tvTwoLevel.setText(addressEntities.get(2).getName().contains("总包") ? addressEntities.get(2).getName() : String.format("总包%s", addressEntities.get(2).getName()));
                mBinding.tvThreeLevel.setText(addressEntities.get(3).getName().contains("总包") ? addressEntities.get(3).getName() : String.format("总包%s", addressEntities.get(3).getName()));
            } else {
                mHaveLevel = false;
                mLevel = new ArrayList<>();
            }
        });

        mViewModel.mSuccessMemberCompany.observe(getViewLifecycleOwner(), addressEntities -> {
            mBinding.swipeRefresh.setRefreshing(false);
            if (addressEntities != null && addressEntities.size() > 0) {
                mMemberCompanyAdapter.setDatas(addressEntities);
                mBinding.rvMemberCompany.setVisibility(View.VISIBLE);
                mBinding.rvMemberCompanyNoData.setVisibility(View.INVISIBLE);
                mBinding.ivMemberArrow.setVisibility(View.GONE);
            } else {
                mBinding.rvMemberCompany.setVisibility(View.INVISIBLE);
                mBinding.rvMemberCompanyNoData.setVisibility(View.VISIBLE);
                if (mTitleNumber == 3) {
                    mBinding.ivMemberArrow.setVisibility(View.GONE);
                } else if (mTitleNumber == 0 || mTitleNumber == 1 || mTitleNumber == 2) {
                    mBinding.ivMemberArrow.setVisibility(View.VISIBLE);
                    mBinding.ivMemberArrow.setText(mJumpStr);
                }
                mBinding.rvMemberCompanyNoData.setText(mToastStr);
            }
        });

        mViewModel.mSuccessWorkKind.observe(getViewLifecycleOwner(), pickFilterEntities -> {
            List<PickFilterEntity> list = new ArrayList<>(pickFilterEntities);
            mWorkKindOne = new OptionsPickerBuilder(getContext(), (options1, options2, options3, v) -> {
                mBinding.tvSelectType.setText(list.get(options1).getName());
                mWorkKindOneNo = list.get(options1).getNo();
                mWorkKindOneName = list.get(options1).getName();
                mWorkKindOnePosition = options1;
                mBinding.ivNation8.setVisibility(View.VISIBLE);
                mWorkKind = pickFilterEntities.get(options1).getChildren();
            }).setCancelColor(ContextCompat.getColor(getContext(), R.color.color_666666)).setTitleColor(ContextCompat.getColor(getContext(), R.color.color_969696)).build();
            mWorkKindOne.setPicker(list);
            mWorkKindOne.setSelectOptions(mWorkKindOnePosition);
            mWorkKindOne.setTitleText("请选择类型");
            mWorkKindOne.show();
        });

        mViewModel.mSuccessCompany.observe(getViewLifecycleOwner(), new Observer<SparseArray<List<AddressEntity>>>() {
            @Override
            public void onChanged(SparseArray<List<AddressEntity>> listSparseArray) {
                mMainCompany = new TeamMainCompanyPupWindow(getContext());
                mMainCompany.setDataRecommend(listSparseArray.get(0));
                mMainCompany.setDataLeaguer(listSparseArray.get(1));
                mMainCompany.setDataMember(listSparseArray.get(2));
                mMainCompany.setDataAttend(listSparseArray.get(3));
                mMainCompany.setClippingEnabled(false);
                mMainCompany.showPopwindow(mBinding.ivOpenCompanyList, Gravity.BOTTOM, 0, 0);
            }
        });
    }

    private void initStatusLiveData() {
        mViewModel.loadingLiveData.observe(getViewLifecycleOwner(), aBoolean -> DialogHelper.showProgressDialog(getContext(), null, "数据加载中...", 0, false, null).setCanceledOnTouchOutside(false));
        mViewModel.successLiveData.observe(getViewLifecycleOwner(), aBoolean -> DialogHelper.dismissProgressDialog());
        mViewModel.errorLiveData.observe(getViewLifecycleOwner(), aBoolean -> {
            mBinding.swipeRefresh.setRefreshing(false);
            DialogHelper.dismissProgressDialog();
        });
    }

    private void initData() {
        mViewModel.getLinkAgeWorkType(true);
        refresh();

        mViewModel.getIntelligenceLevel();
    }

    private View createHeaderView() {
        View headerView = LayoutInflater.from(mBinding.swipeRefresh.getContext()).inflate(R.layout.super_swipe_refresh_head, null);
        ProgressBar progressBar = headerView.findViewById(R.id.pb_view);
        textView = headerView.findViewById(R.id.text_view);
        textView.setText("下拉刷新");
        progressBar.setVisibility(View.GONE);
        return headerView;
    }

    private void initViews() {
        mBinding.swipeRefresh.setHeaderView(createHeaderView());
        mBinding.swipeRefresh.setEnabled(false);
        mBinding.appBarLayout.addOnOffsetChangedListener((appBarLayout, i) -> mBinding.swipeRefresh.setEnabled(i >= 0));
        mBinding.swipeRefresh.setOnPullRefreshListener(new SuperSwipeRefreshLayout.OnPullRefreshListener() {
            @Override
            public void onRefresh() {
                textView.setText("正在刷新");

                mBinding.ttvTop.setCheckedPosition(0);
                mBinding.ttvTop.closeExpand(false);
                mBinding.teamMenu.closeExpand(false);
                if (menuList == null || menuList.size() <= 10){
                    mBinding.teamMenu.imageCancel();
                }
                mBinding.tlPackerChangeFirstPublishTitle.postDelayed(() -> mBinding.tlPackerChangeFirstPublishTitle.getTabAt(0).select(), 100);

                mBinding.llPackerChangeFirstPublishFindWorker.setVisibility(View.VISIBLE);
                mBinding.llPublishFindWork.setVisibility(View.GONE);
                mBinding.llPublishFindWorkType.setVisibility(View.GONE);

                refresh();
                mViewModel.getIntelligenceLevel();

                doRefresh();
            }

            @Override
            public void onPullDistance(int distance) {

            }

            @Override
            public void onPullEnable(boolean enable) {
                textView.setText(enable ? "释放立即刷新" : "下拉刷新");
            }
        });

        mBinding.ttvTop.setData(mViewModel.getContentTitle());

        mBinding.ttvTop.setTopViewOfInter(new TopView.TopViewOfInter<Integer>() {
            @Override
            public void itemClick(Integer s, List<Integer> parent, int position, int childPosition) {
                switch (position) {
                    case 0:
                        switch (childPosition) {
                            case 0:
                                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",0));
                                break;
                            case 1:
                                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",1));
                                break;
                            case 2:
                                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",2));
                                 break;
                            case 5:
                                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",5));
                                break;
                            case 3:
                                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",3));
                                break;
                            case 4:
                                com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",4));
                            default:
                                break;
                        }
                        break;
                    case 1:
                        com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",6));
                        break;
                    default:
                        break;
                }
            }

            @Override
            public void refresh() {
                mBinding.llLevel.setVisibility(View.GONE);
                mViewModel.getLinkAgeWorkType(true);
            }
        });

        mBinding.tlPackerChangeFirstPublishTitle.addTab(mBinding.tlPackerChangeFirstPublishTitle.newTab().setText("快速招工"));
        mBinding.tlPackerChangeFirstPublishTitle.addTab(mBinding.tlPackerChangeFirstPublishTitle.newTab().setText("工人找活"));
        mBinding.tlPackerChangeFirstPublishTitle.addTab(mBinding.tlPackerChangeFirstPublishTitle.newTab().setText("找专业工队"));

        mBinding.tlPackerChangeFirstPublishTitle.addOnTabSelectedListener(new CustomXTabLayout.SimpleSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                super.onTabSelected(tab);
                if (tab.getPosition() == 0) {
                    mBinding.llPackerChangeFirstPublishFindWorker.setVisibility(View.VISIBLE);
                    mBinding.llPublishFindWork.setVisibility(View.GONE);
                    mBinding.llPublishFindWorkType.setVisibility(View.GONE);
                    position = 0;
                } else if (tab.getPosition() == 1) {
                    mBinding.llPackerChangeFirstPublishFindWorker.setVisibility(View.GONE);
                    mBinding.llPublishFindWork.setVisibility(View.VISIBLE);
                    mBinding.llPublishFindWorkType.setVisibility(View.GONE);
                    position = 1;
                } else if (tab.getPosition() == 2) {
                    mBinding.llPackerChangeFirstPublishFindWorker.setVisibility(View.GONE);
                    mBinding.llPublishFindWork.setVisibility(View.GONE);
                    mBinding.llPublishFindWorkType.setVisibility(View.VISIBLE);
                    position = 2;
                }
            }
        });


        mBinding.tlPackerChangeFirstTitle.addTab(mBinding.tlPackerChangeFirstTitle.newTab().setText(title[0]));
        mBinding.tlPackerChangeFirstTitle.addTab(mBinding.tlPackerChangeFirstTitle.newTab().setText(title[1]));
        mBinding.tlPackerChangeFirstTitle.addTab(mBinding.tlPackerChangeFirstTitle.newTab().setText(title[2]));
        mBinding.tlPackerChangeFirstTitle.addTab(mBinding.tlPackerChangeFirstTitle.newTab().setText(title[3]));


        mBinding.tlPackerChangeFirstTitle.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                int pos = tab.getPosition();

                mBinding.rlPackerChangeSecond.setCurrentItem(pos);
                Fragment fragment = list.get(pos);
                if (fragment instanceof PackersChangeListItemFragment) {
                    ((PackersChangeListItemFragment) fragment).onRefresh();
                }
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });


        GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 3);
        mMemberCompanyAdapter = new MemberCompanyAdapter(getContext(), null);
        mMemberCompanyAdapter.setOnItemClick(new AdapterOnItemClick<AddressEntity>() {
            @Override
            public void onItemClick(AddressEntity addressEntity, int position) {
                WebsiteInfoActivity.start(getActivity(), addressEntity.getNo(), WebsiteInfoActivity.WEBSITE_FOR_COMPANY);
            }
        });
        mBinding.rvMemberCompany.setLayoutManager(gridLayoutManager);
        mBinding.rvMemberCompany.setAdapter(mMemberCompanyAdapter);

        mBinding.tvSex.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (!TextUtils.isEmpty(mBinding.tvSex.getText().toString())) {
                    mBinding.ivNation1.setVisibility(View.VISIBLE);
                } else {
                    mBinding.ivNation1.setVisibility(View.GONE);
                }
            }
        });
        mBinding.etWorkerPersonNumber.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (!TextUtils.isEmpty(mBinding.etWorkerPersonNumber.getText().toString())) {
                    mBinding.ivNation7.setVisibility(View.VISIBLE);
                } else {
                    mBinding.ivNation7.setVisibility(View.GONE);
                }
            }
        });

        mBinding.tvWorkSelectSubpackageWay.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (!TextUtils.isEmpty(mBinding.tvWorkSelectSubpackageWay.getText().toString())) {
                    mBinding.ivNation11.setVisibility(View.VISIBLE);
                } else {
                    mBinding.ivNation11.setVisibility(View.GONE);
                }
            }
        });

        mBinding.etInputAgeEt.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (!TextUtils.isEmpty(mBinding.etInputAgeEt.getText().toString())) {
                    mBinding.ivNation12.setVisibility(View.VISIBLE);
                } else {
                    mBinding.ivNation12.setVisibility(View.GONE);
                }
            }
        });
    }

    @Override
    protected void onLazyLoad() {
        initData();

        list = new ArrayList<>();
        list.add(PackersChangeListItemFragment.newInstance(0));
        list.add(PackersChangeListItemFragment.newInstance(1));
        list.add(PackersChangeListItemFragment.newInstance(2));
        list.add(PackersChangeListItemFragment.newInstance(6));
        CommPagerAdapter pagerAdapter = new CommPagerAdapter(getChildFragmentManager(), list, title);
        mBinding.rlPackerChangeSecond.setAdapter(pagerAdapter);
        mBinding.tlPackerChangeFirstTitle.setupWithViewPager(mBinding.rlPackerChangeSecond);
        mBinding.rlPackerChangeSecond.setOffscreenPageLimit(3);
    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
        if (isVisibleToUser) {
            if (SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0) != mUserType) {
                refresh();
            }

            mUserType = SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0);
        }
    }

    @Override
    public void onHiddenChanged(boolean isVisibleToUser) {
        super.onHiddenChanged(isVisibleToUser);
        if (isVisibleToUser) {
            if (SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0) != mUserType) {
                refresh();
            }

            mUserType = SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0);
        }
    }

    private void initButtonListener() {
        mBinding.tvSelectWorkType.setOnClickListener(this);
        mBinding.tvSelectSalaryMethod.setOnClickListener(this);
        mBinding.ivMemberArrow.setOnClickListener(this);
        mBinding.tvSpecialLevel.setOnClickListener(this);
        mBinding.tvOneLevel.setOnClickListener(this);
        mBinding.tvTwoLevel.setOnClickListener(this);
        mBinding.tvThreeLevel.setOnClickListener(this);
        mBinding.etInputWorkArea.setOnClickListener(this);
        mBinding.etInputAge.setOnClickListener(this);
        mBinding.tvSelectWorkProfessionalLevel.setOnClickListener(this);
        mBinding.etInputWorkArea.setOnClickListener(this);
        mBinding.etInputWorkAge.setOnClickListener(this);
        mBinding.ivNation.setOnClickListener(this);
        mBinding.ivNation1.setOnClickListener(this);
        mBinding.ivNation2.setOnClickListener(this);
        mBinding.ivNation3.setOnClickListener(this);
        mBinding.ivNation4.setOnClickListener(this);
        mBinding.ivNation5.setOnClickListener(this);
        mBinding.ivNation6.setOnClickListener(this);
        mBinding.ivNation7.setOnClickListener(this);
        mBinding.ivNation8.setOnClickListener(this);
        mBinding.ivNation9.setOnClickListener(this);
        mBinding.ivNation10.setOnClickListener(this);
        mBinding.ivNation11.setOnClickListener(this);
        mBinding.rvMemberCompanyNoData.setOnClickListener(this);
        mBinding.etInputWorkClassify.setOnClickListener(this);
        mBinding.tvSelectType.setOnClickListener(this);
        mBinding.tvMate.setOnClickListener(this);
        mBinding.tvMate1.setOnClickListener(this);
        mBinding.tvMate2.setOnClickListener(this);
        mBinding.tvWorkNumber.setOnClickListener(this);
        mBinding.ivWorkClassify1.setOnClickListener(this);
        mBinding.ivOpenCompanyList.setOnClickListener(this);
        mBinding.ivNation12.setOnClickListener(this);
    }

    @LoginCheck(needRealName = true)
    public void mate(){
        if (position == 0) {
            if (TextUtils.isEmpty(mBinding.tvSelectWorkType.getText().toString()) && TextUtils.isEmpty(mBinding.tvSex.getText().toString()) && TextUtils.isEmpty(mBinding.etInputWorkAge.getText().toString()) && TextUtils.isEmpty(mBinding.etInputWorkArea.getText().toString())) {
                MToast.showToast(getContext(), "请至少选择一个选项进行匹配");
                return;
            }

        } else if (position == 1) {
            if (TextUtils.isEmpty(mBinding.etInputAge.getText().toString()) && TextUtils.isEmpty(mBinding.tvSelectWorkProfessionalLevel.getText().toString()) && TextUtils.isEmpty(mBinding.etWorkerPersonNumber.getText().toString()) && TextUtils.isEmpty(mBinding.tvSelectSalaryMethod.getText().toString()) && TextUtils.isEmpty(mBinding.etInputAgeEt.getText().toString())) {
                MToast.showToast(getContext(), "请至少选择一个选项进行匹配");
                return;
            }
        } else if (position == 2) {
            if (TextUtils.isEmpty(mBinding.tvSelectType.getText().toString()) && TextUtils.isEmpty(mBinding.tvWorkNumber.getText().toString()) && TextUtils.isEmpty(mBinding.etInputWorkClassify.getText().toString()) && TextUtils.isEmpty(mBinding.tvWorkSelectSubpackageWay.getText().toString())) {
                MToast.showToast(getContext(), "请至少选择一个选项进行匹配");
                return;
            }
        }

        if (position == 0) {
            com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",1), Pair.create("provinceNo", mProvince == null ? "" : mProvince), Pair.create("time", mBinding.etInputWorkAge.getText().toString())
                    , Pair.create("industryNo", position == 0 ? (mIndustryNo==null ? "" : mIndustryNo) : mIndustryNoTwo), Pair.create("categoryNo", position == 0 ? (mCategoryNo == null ? "" : mCategoryNo) : mCategoryNoTwo), Pair.create("workNo", position == 0 ? (mWorkNo == null ? "" : mWorkNo) : mWorkNoTwo)
                    , Pair.create("cityNo", position == 0 ? (mCity == null ? "" : mCity) : mCityTwo), Pair.create("workName", mBinding.tvSelectWorkType.getText().toString()), Pair.create("cityName", position == 0 ? (mCityName == null ? "" : mCityName) : mCityNameTwo));
        } else if (position == 1) {
            com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",0),Pair.create("salaryType", mSalaryTypeNo == null ? "" : mSalaryTypeNo)
                    , Pair.create("industryNo", mIndustryNoTwo == null ? "" : mIndustryNoTwo), Pair.create("categoryNo", mCategoryNoTwo == null ? "" : mCategoryNoTwo), Pair.create("workNo", mWorkNoTwo == null ? "" : mWorkNoTwo), Pair.create("provinceNo", mProvinceTwo == null ? "" : mProvinceTwo), Pair.create("cityNo", mCityTwo == null ? "" : mCityTwo)
                    , Pair.create("cityName", mCityNameTwo == null ? "" : mCityNameTwo), Pair.create("industryName", mIndustryNameTwo == null ? "" : mIndustryNameTwo), Pair.create("areaNo", mAreaNo == null ? "" : mAreaNo));
        } else if (position == 2) {
            com.swgk.core.common.utils.ActivityJump.startActivity(PathTeam.PackersTabActivity,Pair.create("type",2),Pair.create("workKindOne", mWorkKindOneNo == null ? "" : mWorkKindOneNo), Pair.create("workKindTwo", mWorkKindTwoNo == null ? "" : mWorkKindTwoNo), Pair.create("workKindThree", mWorkKindThreeNo == null ? "" : mWorkKindThreeNo), Pair.create("workName", TextUtils.isEmpty(mWorkKindTwoName) ? (mWorkKindOneName == null ? "" : mWorkKindOneName) : (mWorkKindTwoName == null ? "" : mWorkKindTwoName.replace("-", ""))), Pair.create("publishTime", mBinding.tvWorkNumber.getText().toString()));
        }
    }

    @Override
    public void onMultiClick(View v) {
        super.onMultiClick(v);
        int id = v.getId();
        if (id == R.id.rv_member_company_no_data) {
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                VerificationCodeLoginActivity.start(getActivity(), false);
            }
        } else if (id == R.id.iv_open_company_list) {
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                VerificationCodeLoginActivity.start(getActivity(), false);
            } else {
                mViewModel.getRecommendList(1, SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""));
            }
        } else if (id == R.id.iv_member_arrow) {
            if (mTitleNumber == 0) {
                mUserType = SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0);
                if (mUserType == 1) {
                    InviteMemberListActivity.launch(getContext());
                } else {
                    MToast.showToast(getContext(), "请切换为企业身份邀请");
                }
            } else if (mTitleNumber == 1) {
                MemberInviteOrApplyActivity.startInviteOrApply(getActivity(), 0);
            } else if (mTitleNumber == 2) {
                String longitude = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LONGITUDE_ID, "");
                String latitude = SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LATITUDE_ID, "");
                ActivityJump.jumpToActivity(getActivity(), ManageActivity.class, Pair.create("latitude", latitude), Pair.create("longitude", longitude));
            }
        } else if (id == R.id.tv_select_work_type || id == R.id.et_input_age) {
            mViewModel.getLinkAgeWorkType(false);
        } else if (id == R.id.et_input_work_area || id == R.id.tv_select_work_professional_level) {
            mViewModel.getCityList();
        } else if (id == R.id.tv_special_level) {
            ActivityJump.jumpToActivity(getContext(), PackersEngineeringCompanyActivity.class, Pair.create("mQualificationClassNo", mLevel.get(0).getNo()), Pair.create("mQualificationClassName", mLevel.get(0).getName()));
        } else if (id == R.id.tv_one_level) {
            ActivityJump.jumpToActivity(getContext(), PackersEngineeringCompanyActivity.class, Pair.create("mQualificationClassNo", mLevel.get(1).getNo()), Pair.create("mQualificationClassName", mLevel.get(1).getName()));
        } else if (id == R.id.tv_two_level) {
            ActivityJump.jumpToActivity(getContext(), PackersEngineeringCompanyActivity.class, Pair.create("mQualificationClassNo", mLevel.get(2).getNo()), Pair.create("mQualificationClassName", mLevel.get(2).getName()));
        } else if (id == R.id.tv_three_level) {
            ActivityJump.jumpToActivity(getContext(), PackersEngineeringCompanyActivity.class, Pair.create("mQualificationClassNo", mLevel.get(3).getNo()), Pair.create("mQualificationClassName", mLevel.get(3).getName()));
        } else if (id == R.id.tv_select_salary_method) {
            showSalaryFsPop(mViewModel.getSalaryFs());
        } else if (id == R.id.tv_mate || id == R.id.tv_mate_1 || id == R.id.tv_mate_2) {
            mate();
        } else if (id == R.id.iv_nation) {
            mIndustryNo = "";
            mIndustryName = "";
            mCategoryNo = "";
            mWorkNo = "";
            mBinding.tvSelectWorkType.setText("");
            mBinding.ivNation.setVisibility(View.GONE);
            mWorkCityPosition1 = 0;
            mWorkCityPosition2 = 0;
            mWorkCityPosition3 = 0;
        } else if (id == R.id.iv_nation_1) {
            mBinding.tvSex.setText("");
            mBinding.ivNation1.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_2) {
            mCity = "";
            mProvince = "";
            mCityName = "";
            mProvincePosition = 0;
            mCityPosition = 0;
            mBinding.etInputWorkArea.setText("");
            mBinding.ivNation2.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_3) {
            mBinding.etInputWorkAge.setText("");
            timeEndPicker = null;
            mBinding.ivNation3.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_4) {
            mIndustryNoTwo = "";
            mIndustryNameTwo = "";
            mCategoryNoTwo = "";
            mWorkNoTwo = "";
            mBinding.etInputAge.setText("");
            mWorkCityPositionTwo1 = 0;
            mBinding.ivNation4.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_5) {
            mBinding.tvSelectSalaryMethod.setText("");
            mSalaryTypeNo = "";
            selectPosition = 0;
            mBinding.ivNation5.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_6) {
            mBinding.tvSelectWorkProfessionalLevel.setText("");
            mCityTwo = "";
            mProvinceTwo = "";
            mCityNameTwo = "";
            mProvincePositionTwo = 0;
            mCityPositionTwo = 0;
            mBinding.ivNation6.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_7) {
            mBinding.etWorkerPersonNumber.setText("");
            mBinding.ivNation7.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_8) {
            mBinding.tvSelectType.setText("");
            mBinding.etInputWorkClassify.setText("");
            mWorkKindOneNo = "";
            mWorkKindOneName = "";
            mWorkKindTwoNo = "";
            mWorkKindTwoName = "";
            mWorkKindThreeNo = "";
            mWorkKindOnePosition = 0;
            mWorkKindTwoPosition = 0;
            mWorkKindThreePosition = 0;
            mBinding.ivNation10.setVisibility(View.GONE);
            mBinding.ivNation8.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_9) {
            mBinding.tvWorkNumber.setText("");
            timeEndPicker1 = null;
            mBinding.ivWorkClassify1.setVisibility(View.VISIBLE);
            mBinding.ivNation9.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_10) {
            mBinding.etInputWorkClassify.setText("");
            mWorkKindTwoNo = "";
            mWorkKindThreeNo = "";
            mWorkKindTwoName = "";
            mWorkKindTwoPosition = 0;
            mWorkKindThreePosition = 0;
            mBinding.ivNation10.setVisibility(View.GONE);
        } else if (id == R.id.iv_nation_11) {
            mBinding.tvWorkSelectSubpackageWay.setText("");
            mBinding.ivNation11.setVisibility(View.GONE);
        } else if (id == R.id.et_input_work_classify) {
            if ("".equals(mBinding.tvSelectType.getText().toString())) {
                MToast.showToast(getContext(), "请先选择类型");
                return;
            }
            showWorkKindTwo();
        } else if (id == R.id.tv_select_type) {
            mViewModel.getCategoryType();
        } else if (id == R.id.et_input_work_age) {
            Calendar day = Calendar.getInstance();
            if (timeEndPicker == null) {
                timeEndPicker = new TimePickerBuilder(getContext(), new OnTimeSelectListener() {
                    @Override
                    public void onTimeSelect(Date date, View v) {
                        Calendar cal1 = Calendar.getInstance();
                        cal1.setTime(date);
                        cal1.set(Calendar.HOUR_OF_DAY, 23);
                        cal1.set(Calendar.MINUTE, 59);
                        cal1.set(Calendar.SECOND, 59);
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        String format = sdf.format(date);

                        mBinding.etInputWorkAge.setText(format);
                        mBinding.ivNation3.setVisibility(View.VISIBLE);
                    }
                }).setTitleText("请选择时间").setRangDate(null, day).setTitleColor(ContextCompat.getColor(getContext(), R.color.color_969696)).build();
            }

            timeEndPicker.show();
        } else if (id == R.id.tv_work_number || id == R.id.iv_work_classify_1) {
            Calendar day = Calendar.getInstance();
            if (timeEndPicker1 == null) {
                timeEndPicker1 = new TimePickerBuilder(getContext(), new OnTimeSelectListener() {
                    @Override
                    public void onTimeSelect(Date date, View v) {
                        Calendar cal1 = Calendar.getInstance();
                        cal1.setTime(date);
                        cal1.set(Calendar.HOUR_OF_DAY, 23);
                        cal1.set(Calendar.MINUTE, 59);
                        cal1.set(Calendar.SECOND, 59);
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        String format = sdf.format(date);

                        mBinding.tvWorkNumber.setText(format);
                        mBinding.ivNation9.setVisibility(View.VISIBLE);
                        mBinding.ivWorkClassify1.setVisibility(View.INVISIBLE);
                    }
                }).setTitleText("请选择时间").setRangDate(null, day).setTitleColor(ContextCompat.getColor(getContext(), R.color.color_969696)).build();
            }
            timeEndPicker1.show();
        } else if (id == R.id.iv_nation_12) {
            mBinding.etInputAgeEt.setText("");
            mBinding.ivNation12.setVisibility(View.INVISIBLE);
        }
    }

    /**
     * 薪资方式
     *
     * @param list 薪资方式的数据
     */
    public void showSalaryFsPop(List<PickSelectEntity> list) {
        OptionsPickerView projectCategoryOption = new OptionsPickerBuilder(getContext(), (options1, options2, options3, v) -> {
            mBinding.tvSelectSalaryMethod.setText(list.get(options1).getProjectscale());
            mSalaryTypeNo = list.get(options1).getNo();
            selectPosition = options1;
            mBinding.ivNation5.setVisibility(View.VISIBLE);
        }).setCancelColor(ContextCompat.getColor(getContext(), R.color.color_666666)).setTitleColor(ContextCompat.getColor(getContext(), R.color.color_969696)).build();
        projectCategoryOption.setPicker(list);
        projectCategoryOption.setSelectOptions(selectPosition);
        projectCategoryOption.setTitleText("请选择薪资方式");
        projectCategoryOption.show();
    }

    private void doRefresh() {
        int pos = mBinding.rlPackerChangeSecond.getCurrentItem();
        if (list == null || list.size() == 0) {
            return;
        }
        Fragment fragment = list.get(pos);
        if (fragment instanceof PackersChangeListItemFragment) {
            ((PackersChangeListItemFragment) fragment).onRefresh();
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        if (sIsBack == 1) {
            mBinding.tvSex.setText("");
            mBinding.tvSelectWorkType.setText("");
            mBinding.tvSelectSalaryMethod.setText("");
            mBinding.etWorkerPersonNumber.setText("");
            mBinding.etInputWorkAge.setText("");
            mBinding.etInputAge.setText("");
            mBinding.etWorkerPersonNumber.clearFocus();
            mBinding.etInputWorkAge.clearFocus();
            mBinding.etInputAge.clearFocus();

            sIsBack = -1;
        }

        mUserType = SharedPreferenceUtil.getInstance().getSaveIntData(SharedPreferenceUtil.COM_TYPE, 0);
    }

    public void refresh() {
        if (mTitleNumber == 3) {
            mViewModel.getNewList();
        } else {
            if ("".equals(SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.LOGIN_TOKEN, ""))) {
                mBinding.rvMemberCompanyNoData.setText("您暂未登录，请登录后查看");
                mBinding.rvMemberCompany.setVisibility(View.GONE);
                mBinding.ivMemberArrow.setVisibility(View.GONE);
                mBinding.rvMemberCompanyNoData.setVisibility(View.VISIBLE);
                mBinding.ivMemberArrow.setVisibility(View.GONE);
                mBinding.swipeRefresh.setRefreshing(false);
            } else {
                mBinding.rvMemberCompanyNoData.setVisibility(View.GONE);
                if (mTitleNumber == 0) {
                    mViewModel.leaguerCompany();
                } else if (mTitleNumber == 1) {
                    mViewModel.memberCompany();
                } else if (mTitleNumber == 2) {
                    mViewModel.getCompanyList(1, SharedPreferenceUtil.getInstance().getSaveStringData(SharedPreferenceUtil.USER_NO, ""));
                }
            }
        }
    }

    private void showWorkKindTwo() {
        if (mWorkKind == null) {
            MToast.showToast(getContext(), "当前分类下没有子分类");
            return;
        }

        if (mWorkKind.size() <= 0) {
            MToast.showToast(getContext(), "当前分类下没有子分类");
            return;
        }

        List<List<PickFilterEntity>> workKind = new ArrayList<>();
        for (PickFilterEntity<List<PickFilterEntity>> listPickFilterEntity : mWorkKind) {
            if (listPickFilterEntity.getChildren() != null) {
                workKind.add(listPickFilterEntity.getChildren());
            } else {
                workKind.add(new ArrayList<>());
            }
        }

        CityPickView mWorkKindTwo = new CityPickBuilder(getContext(), (options1, options2, options3, v) -> {
            String content = "";
            if (workKind.get(options1).size() > 0) {
                content = mWorkKind.get(options1).getName()
                        +
                        (TextUtils.isEmpty(workKind.get(options1).get(options2).getName()) ? "" : "/" + workKind.get(options1).get(options2).getName());
            } else {
                content = mWorkKind.get(options1).getName();
            }
            mBinding.etInputWorkClassify.setText(content);
            mWorkKindTwoPosition = options1;
            mWorkKindThreePosition = options2;
            mWorkKindTwoNo = mWorkKind.get(options1).getNo();
            if (workKind.get(options1).size() > 0) {
                mWorkKindThreeNo = workKind.get(options1).get(options2).getNo();
            }
            if (workKind.get(options1).size() > 0) {
                mWorkKindTwoName = TextUtils.isEmpty(workKind.get(options1).get(options2).getName()) ? mWorkKind.get(options1).getName() : "-" + workKind.get(options1).get(options2).getName();
            } else {
                mWorkKindTwoName = mWorkKind.get(options1).getName();
            }
            mBinding.ivNation10.setVisibility(View.VISIBLE);
        }).setCancelColor(ContextCompat.getColor(getContext(), R.color.color_666666)).setTitleColor(ContextCompat.getColor(getContext(), R.color.color_969696)).build();
        mWorkKindTwo.setPicker(mWorkKind, workKind);
        mWorkKindTwo.setSelectOptions(mWorkKindTwoPosition, mWorkKindThreePosition);
        mWorkKindTwo.setTitleText("请选择工程分类");
        mWorkKindTwo.show();
    }
}
